package com.example.lock.乐观锁.cas;

public class TestNormal {

    private static volatile int a = 0;

    public static void main(String[] args) {

        TestNormal testNormal = new TestNormal();
        Thread[] threads = new Thread[5];
        //定义五个线程，每个线程加10
        for(int i = 0;i<5;i++){
            threads[i] = new Thread(()->{
                try {
                    for(int j = 0;j<10;j++){
                        System.out.println(a++);
                        Thread.sleep(500);
                    }
                }catch (Exception e){
                    e.printStackTrace();
                }
            });
            threads[i].start();
        }
    }
}
